<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>

<script>
    var obj = {
        name: 'xss',
        age: "19",
        sex: 'girl',
        play: function() {
            console.log('paly,,,,,.')
        }
    };
    //改变对象地址的指向
    var objs = obj;
    console.log(objs)

    //-------------浅拷贝-------------------
    function Person(name, age, sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
    Person.prototype.eat = function() {
        console.log(this.name)
        console.log("人吃东西")
    }
    Person.prototype.sleep = function() {
        console.log(this.age)
        console.log("人需要睡觉")
    }
    Person.prototype.play = function() {
        console.log(this.sex)
        console.log("游戏人生")
    }

    var Student = {};
    //遍历存储
    for (let key in Person.prototype) {
        Student[key] = Person.prototype[key];
    }

    console.log(Student)
    Student.name = 'xxx';
    Student.age = '10';
    Student.sex = 'boy';
    Student.eat();
    Student.play();
    Student.sleep();
</script>

</html>